package cn.elwy.rcp.ui.config;

import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.widgets.Control;

import cn.elwy.rcp.core.model.ui.DialogInfo;

/**
 * @author huangsq
 * @version 1.0, 2014-09-04
 * @since 1.0, 2014-09-04
 */
public class DialogConfigListener implements ControlListener {

  private DialogInfo dialogInfo;

  @Override
  public void controlResized(ControlEvent e) {
    Control widget = (Control) e.widget;
    dialogInfo.setX(widget.getLocation().x);
    dialogInfo.setY(widget.getLocation().y);
    dialogInfo.setWidth(widget.getSize().x);
    dialogInfo.setHeight(widget.getSize().y);
  }

  @Override
  public void controlMoved(ControlEvent e) {
    Control control = (Control) e.widget;
    dialogInfo.setX(control.getLocation().x);
    dialogInfo.setY(control.getLocation().y);
    dialogInfo.setWidth(control.getSize().x);
    dialogInfo.setHeight(control.getSize().y);
  }

  public DialogInfo getDialogInfo() {
    return dialogInfo;
  }

  public void setDialogInfo(DialogInfo dialogInfo) {
    this.dialogInfo = dialogInfo;
  }

}
